import java.util.concurrent.LinkedBlockingQueue;

public class BlockQueueStorage {
    private final int MAX_SIZE = 100;

    private LinkedBlockingQueue<Object> list = new LinkedBlockingQueue<>();

    public void produce(Object product) {
        if (list.size() == MAX_SIZE) {
            System.out.println("仓库已满");
        }

        try {
            list.put(product);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("已添加");
    }

    public Object consume() {
        Object res = null;

        if (list.size() == 0) {
            System.out.println("仓库已空");
        }
        try {
            res = list.take();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return res;
    }
}
